<template>
  <div >
    <div>
      <div class="font15 mt10 pl10">
      <span class="titletext ">{{titledata.title}}</span>
      <div class="graytext  mt10 font13">
        <span >工单编号：</span>
        <span class="titletext">{{titledata.pmInsId}}</span>
      </div>
    </div>
    <!-- 基本信息 -->
    <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
      <div class="blue_item" />
      <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">商机数据</span> 
      <van-button v-show="canEdit" block type="info" style="display: inline-block;width:auto;height: 33px;" native-type="button" @click="choseSJ">选择关联商机</van-button>
    </div>
    <van-field readonly required name="opportunitiesNumber" v-model="fromdata.opportunitiesNumber" label="商机编号：" label-width="5em" placeholder="请填写商机编号" :rules="[{ required: true, message: '' }]"/>
    <van-field readonly required autosize type="textarea" name="opportunitiesName" v-model="fromdata.opportunitiesName" label="商机名称：" label-width="5em" placeholder="请填写商机名称" :rules="[{ required: true, message: '' }]"/>
    <van-field readonly required name="cities" :value="fromdata.cities" label="地市：" label-width="3em" placeholder="请填写地市" :rules="[{ required: true, message: '' }]"/>
    <van-field readonly required name="county" :value="fromdata.county" label="县区：" label-width="3em" placeholder="请填写县区" :rules="[{ required: true, message: '' }]"/>
    <van-field readonly name="informant" :value="fromdata.informant" label="商机填报人：" label-width="6em"/>
    <van-field :readonly='!canEdit' name="informantPhone" v-model="fromdata.informantPhone" label="商机填报人联系方式：" label-width="10em" :right-icon="canEdit?'arrow':''"/>
      <van-field readonly autosize type="textarea" rows="1" name="customerName" :value="fromdata.customerName" label="客户单位名称:" label-width="6.5em"/>
      <van-field readonly autosize type="textarea" rows="1" name="customerCode" :value="fromdata.customerCode" label="客户编码:" label-width="4.5em"/>
      <van-field readonly autosize type="textarea" rows="1" name="isProvStrategicCustomer" :value="fromdata.isProvStrategicCustomer=='1'?'是':fromdata.isProvStrategicCustomer=='0'?'否':''" label="是否省级战略客户:" label-width="8.5em"/>
      <van-field readonly autosize type="textarea" rows="1" name="isCityStrategicCustomer" :value="fromdata.isCityStrategicCustomer=='1'?'是':fromdata.isCityStrategicCustomer=='0'?'否':''" label="是否市级战略客户:" label-width="8.5em"/>
      <van-field readonly autosize type="textarea" rows="1" name="industryType" :value="fromdata.industryType" label="客户行业:" label-width="4.5em"/>
      <van-field readonly autosize type="textarea" rows="1" name="preAmount" :value="fromdata.preAmount" label="商机预估金额(万元):" label-width="9.5em"/>
      <van-field readonly name="currentSituation" :value="fromdata.currentSituation" label="当前形势：" label-width="5em" />
    <van-field readonly autosize type="textarea" rows="1" name="dictIntroduction" :value="fromdata.dictIntroduction" label="商机简介：" label-width="5em" />
    <van-field readonly required autosize type="textarea" rows="1" name="buildContent" :value="fromdata.buildContent" label="建设内容：" label-width="5em" placeholder="请填写建设内容" :rules="[{ required: true, message: '' }]"/>
    <van-field :readonly='!canEdit' autosize type="textarea" name="informantDepartment" v-model="fromdata.informantDepartment" label="填报人组织：" label-width="6em"  :right-icon="canEdit?'arrow':''"/>
    <van-field :readonly='!canEdit' name="informantPosition" v-model="fromdata.informantPosition" label="填报人岗位：" label-width="6em"  :right-icon="canEdit?'arrow':''"/>
    <van-field :readonly='!canEdit' name="opportunitiesType" v-model="fromdata.opportunitiesType" label="商机类型：" label-width="5em"  :right-icon="canEdit?'arrow':''"/>
    <van-field :readonly='!canEdit' name="industryType" v-model="fromdata.industryType" label="行业类型：" label-width="5em"  :right-icon="canEdit?'arrow':''"/>
    <van-field :readonly='!canEdit' name="withType" v-model="fromdata.withType" label="业务类型：" label-width="5em"  :right-icon="canEdit?'arrow':''"/>
    <van-field :readonly='!canEdit' name="withBusiness" v-model="fromdata.withBusiness" label="业务场景：" label-width="5em"  :right-icon="canEdit?'arrow':''"/>
    <div v-if="showSQZC">
      <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
        <div class="blue_item" />
        <span span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">售前支撑</span> 
      </div>
      <van-field readonly required name="isSupport" :value="fromdata.isSupport?'是':'否'" label="是否需要省公司支撑：" label-width="10em" />
      <van-field v-if="fromdata.isSupport" readonly required name="provinceSupport" :value="fromdata.provinceSupport" label="省公司支撑处室：" label-width="8em" />
      <van-field readonly name="supportIndustryType" :value="fromdata.supportIndustryType" label="行业类型：" label-width="5em" />
      <van-field readonly name="supportPartner" :value="fromdata.supportPartner" label="支撑合作伙伴：" label-width="7em" />
      <van-field readonly label="应标文档：" label-width="5em" />
      <div v-for="(fileitem) in fromdata.supportProgramList" :key="fileitem.id" style="margin-left:20px">
        <div readonly class="font14 fileLink" style="color:#0F85CF">
          <a target="_blank" @click="openFileUrlfun(fileitem.anonymousFilePath)">{{ fileitem.fileName }}</a>
        </div>
      </div>
      <van-field readonly name="isApply" :value="fromdata.isApply==true?'是':'否'" label="在线资质申请：" label-width="7em" />
      <van-field v-if="fromdata.isApply==true" readonly name="tenderProjectName" :value="fromdata.tenderProjectName" label="招标项目名称：" label-width="7em" />
      <van-field v-if="fromdata.isApply==true" readonly name="watermark" :value="fromdata.watermark" label="水印内容：" label-width="5em" />
      <van-field v-if="fromdata.isApply==true" readonly name="tenderee" :value="fromdata.tenderee" label="招标人：" label-width="4em" />
      <van-field readonly autosize type="textarea" rows="1" name="finallyResult" :value="fromdata.finallyResult" label="备注：" label-width="3em" />
      <!-- <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
      <div class="blue_item" />
        <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">资质库关联表</span> 
        <div v-for="(item,index) in fromdata.qualiConnect" :key="index">  
              <div class="mt10 titletext pl10 font14">
                <span>资质证照名称:</span>
                <span class="titletext">{{item.certificateName}}</span>
              </div>
              <div class="mt5 graytext pl10 font12">
                <span>持证方:</span>
                <span class="titletext">{{item.certificateComp}}</span>
              </div>
              <div class="mt5 graytext pl10">
                <span>证书编号:</span>
                <span class="titletext">{{item.certificateNumb}}</span>
              </div>
              <div class="mt5 graytext pl10">
                <span>证书类型:</span>
                <span class="titletext">{{item.certificateType}}</span>
              </div>
              <div class="mt5 graytext pl10 border-b-1 pb5">
                <span>资质水印件:</span>
                <span class="color-theme">{{item.filePdfList[0].fileName}}</span>
              </div>
            </div>
      </div> -->
    </div>
    
   
    <!-- <van-field readonly required label-width="12em" label="前向合同签约扫描件文件：" />
    <div v-for="(fileitem) in fromdata.oldContractDocument" :key="fileitem.id" style="margin-left:20px">
      <div readonly class="font14 fileLink" style="color:#0F85CF">
        <a target="_blank" @click="openFileUrlfun(fileitem.anonymousFilePath)">{{ fileitem.fileName }}</a>
      </div>
    </div> -->
    <historyAndSuggs id='target' :showHistory='showHistory'
            :historydata='historydata' :approveList='approveList' :isdrawType='isdrawType'/>
    </div>
    
   
  </div>
</template>
 
<script>
import { openFileUrl } from '@/store/openFile'
import historyAndSuggs from "@/views/srqr/historyAndSuggs.vue"
export default {
  data() {
    return {
      sjlistdata:{}
    }
  },
  props: ['canEdit','titledata','businessdata','fromdata','showHistory','historydata','approveList','showSQZC','isdrawType'],
  watch: {
    fromdata: {
      handler () { //这是vue的规定写法，当你watch的值发生变化的时候，就会触发这个handler，这是vue内部帮你做的事情
        console.log('子页面数据发生变化')
        this.$emit('freshData',this.fromdata)
      },
      deep: true,  // 可以深度检测到 obj 对象的属性值的变化
      immediate: true //刷新加载  立马触发一次handler
    },
  }, 
  activated(){
    if(localStorage.getItem('sjlistdata') != '{}' && localStorage.getItem('sjlistdata')){
      this.sjlistdata=JSON.parse(localStorage.getItem('sjlistdata'))
      this.fromdata.opportunitiesNumber=this.sjlistdata.businessId
      this.fromdata.opportunitiesName=this.sjlistdata.businessName
      this.fromdata.cities=this.sjlistdata.city
      this.fromdata.county=this.sjlistdata.county
      this.fromdata.informant=(this.sjlistdata.mgrName!=null&&this.sjlistdata.mgrName!='null')?this.sjlistdata.mgrName:'' 
      this.fromdata.informantPhone=(this.sjlistdata.mgrBill!=null&&this.sjlistdata.mgrBill!='null')?this.sjlistdata.mgrBill:''
      this.fromdata.currentSituation=this.sjlistdata.currentSituation
      this.fromdata.dictIntroduction=this.sjlistdata.projectDesc
      this.fromdata.buildContent=this.sjlistdata.projectDesc 
      this.fromdata.industryType=this.sjlistdata.industryType 
      this.fromdata.withBusiness=this.sjlistdata.withBusiness
      this.fromdata = JSON.parse(JSON.stringify(this.fromdata));
      // this.$emit('freshData',this.fromdata)
    }
    
  },
  methods: {
     tomsg () {
      document.getElementById('target').scrollIntoView({ behavior: 'smooth' })
    },
    openFileUrlfun(value) {
      this.$router.push(
        {
          name: 'fileview',
          query: {
            openFileUrl: openFileUrl(value)
          }
        }
      );
    },
    choseSJ(){ 
      this.$router.push(
        {
          name: 'seletesjlist',
          query: {
            seleteType:'ybzc'
          }
        }
      );
    }
  },
  components: {
    historyAndSuggs
  },
}
</script>
 
<style>
.tables.el-table .cell {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    word-break: break-all;
    line-height: 15px;
    padding-left: 5px;
    padding-right: 5px;
}
</style>